public class Test {
    public String minWindow(String s, String t) {
        int hash1[] = new int[128];
        int hash2[] = new int[128];
        int n = t.length(),kinds = 0;
        for(int i=0;i<n;i++) {
            char ch = t.charAt(i);
            if(hash1[ch]++==0) {
                kinds++;
            }
        }
        int m = s.length();
        int begin = -1, minlen = Integer.MAX_VALUE;
        for(int left = 0,right = 0, count = 0;right<m; right++) {
            char in = s.charAt(right);
            hash2[in]++;
            if(hash2[in]==hash1[in]) {
                count++;
            }
            while(count==kinds) {
                char out = s.charAt(left);
                if(right-left+1<minlen) {
                    minlen = right-left+1;
                    begin = left;
                }
                if(hash2[out]==hash1[out]) {
                    count--;
                }
                hash2[out]--;
                left++;
            }
        }
        if(begin==-1) return "";
        return s.substring(begin,begin+minlen);
    }
}
